package spring.cloud.tasks.common.node;

public final class TaskNodePath {
    public static final String tasks = "/tasks";
    public static final String task_configuration_node = "/task_configuration/";
    public static final String enabled = "enabled";
    public static final String prefer_executor_id_list = "prefer_executor_id_list";

    private TaskNodePath() {
    }


    public static String getTasksNodePath() {
        return "/" + tasks;
    }

    public static String getTaskNodePath(String taskId) {
        return String.format("/%s/%s", tasks, taskId);
    }


    public static String getTaskConfigurationNodePath(final String taskId) {
        return String.format("/%s/%s/task_configuration", tasks, taskId);
    }

    public static String getTaskConfigurationNodePath(final String taskId, final String nodeName) {
        return String.format("/%s/%s/task_configuration/%s", tasks, taskId, nodeName);
    }

    public static String getTaskExecutorsNodePath(final String taskId) {
        return String.format("/%s/%s/executors", tasks, taskId);
    }

    public static String getTaskExecutorNodePath(final String taskId, final String executorId) {
        return String.format("/%s/%s/executors/%s", tasks, taskId, executorId);
    }

    public static String getTaskExecutorNodePath(final String taskId, final String executorId, final String nodeName) {
        return String.format("/%s/%s/%s", getTaskExecutorsNodePath(taskId), executorId, nodeName);
    }

    public static String getTaskItemsNodePath(final String taskId) {
        return String.format("/%s/%s/task_items", tasks, taskId);
    }

    public static String getTaskItemNodePath(final String taskId, final String item, final String nodeName) {
        return String.format("%s/%s/%s", getTaskItemsNodePath(taskId), item, nodeName);
    }

    public static String getRunOneTimePath(final String taskId) {
        return String.format("/%s/%s/runOneTime", tasks, taskId);
    }

    public static String getStopOneTimePath(final String taskId) {
        return String.format("/%s/%s/stopOneTime", tasks, taskId);
    }

    public static String getExecutorStatus(final String taskId, final String executorId) {
        return String.format("/%s/%s/executors/%s/status", tasks, taskId, executorId);
    }

    public static String getServerSharding(final String taskId, final String executorId) {
        return String.format("/%s/%s/executors/%s/sharding", tasks, taskId, executorId);
    }


    public static String getTaskConfigForceShardNodePath(String taskId) {
        return String.format("/%s/%s/forceShard", tasks, taskId);
    }

    public static String getTaskConfigSignatureNodePath(String taskId) {
        return String.format("/%s/%s/%s", tasks, taskId, "signature");
    }

    public static String getTaskNodePath(final String taskId, final String node) {
        return String.format("/%s/%s/%s", tasks, taskId, node);
    }


    public static String getTaskExecutorNode(String taskId, String executorId) {
        return getTaskNodePath(taskId, "/executors/" + executorId);
    }


}
